package org.retabel.service.render;

import org.retabel.persistence.entity.report.RenderingEngineEnum;
import org.retabel.service.render.exporter.FopRenderingEngine;
import org.retabel.service.render.exporter.JasperReportsRenderingEngine;
import org.retabel.service.render.exporter.RenderingEngine;

import java.net.URI;

/**
 * Class to create specific RenderEngine instances.
 * <p/>
 * <h3>Extra-Info</h3>
 * Created: 17:37 21.03.12
 *
 * @author Burt Parkers
 * @version 1.0
 */
public class RenderEngineFactory {

    /**
     * Creates a specific RenderEngine instance by enum.
     *
     * @param renderingEngineEnum the RenderEngine enum.
     * @return a specific instance.
     */
    public static RenderingEngine create(RenderingEngineEnum renderingEngineEnum, URI reportDesignURI) {
        switch (renderingEngineEnum) {
            case JASPER_REPORTS:
                return new JasperReportsRenderingEngine();
            case FOP:
                return new FopRenderingEngine(reportDesignURI);
            default:
                // Implementation error
                throw new RuntimeException("Cannot create RenderEngine for " + renderingEngineEnum);
        }
    }
}
